package org.hawk.gwtppc.webtest.tests.classsuite;

import java.lang.reflect.TypeVariable;
import java.util.RandomAccess;

import org.hawk.gwtppc.webtest.common.Asserts;
import org.hawk.gwtppc.webtest.common.Test;
import org.hawk.gwtppc.webtest.tests.mock.GenericClassMock;

public class GetTypeParametersTest implements Test {

	public void run() throws Throwable {
		Asserts.assertEquals(GenericClassMock.class.getTypeParameters().length, 3);
		Asserts.assertEquals(GenericClassMock.class.getTypeParameters()[0].toString(), "X1");
		Asserts.assertEquals(GenericClassMock.class.getTypeParameters()[1].toString(), "X2");
		Asserts.assertEquals(GenericClassMock.class.getTypeParameters()[2].toString(), "X3");
		
		Asserts.assertEquals(GenericClassMock.class.getTypeParameters()[0].getName(), "X1");
		Asserts.assertEquals(GenericClassMock.class.getTypeParameters()[1].getName(), "X2");
		Asserts.assertEquals(GenericClassMock.class.getTypeParameters()[2].getName(), "X3");
		
		Asserts.assertEquals(GenericClassMock.class.getTypeParameters()[0].getBounds().length, 2);
		Asserts.assertEquals(GenericClassMock.class.getTypeParameters()[1].getBounds().length, 0);
		Asserts.assertEquals(GenericClassMock.class.getTypeParameters()[2].getBounds().length, 0);
		
		TypeVariable<?> var = GenericClassMock.class.getTypeParameters()[0];
		Asserts.assertEquals(var.getBounds()[0], CharSequence.class);
		Asserts.assertEquals(var.getBounds()[1], RandomAccess.class);
		Asserts.assertEquals(var.getGenericDeclaration(), GenericClassMock.class);
	}

	public String getName() {
		return "getTypeParameters()";
	}

}
